package com.zf.shuashua.ui.mine;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseViewHolder;
import com.meis.base.mei.adapter.MeiBaseAdapter;
import com.zf.shuashua.R;
import com.zf.shuashua.api.Store;
import com.zf.shuashua.bean.FocusList;

import java.util.List;

public class FocusListAdapter extends MeiBaseAdapter<FocusList.DataBean> {
    private TextView btFans;

    public FocusListAdapter(int layoutResId, @Nullable List<FocusList.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(final BaseViewHolder helper, final FocusList.DataBean item) {
        if (item.getUser() != null) {
            helper.setText(R.id.tvName, item.getUser().getName()).setText(R.id.tvSign, item.getUser().getSignature()).addOnClickListener(R.id.tvIsFocus);
            Glide.with(mContext)
                    .load(item.getUser().getAvatar() + "")
                    .circleCrop()
                    .into((ImageView) helper.getView(R.id.imgAvatar));
            btFans = helper.getView(R.id.tvIsFocus);
            if (Store.getInstance().getuserId().equals(item.getUser().getId() + "")) {
                btFans.setVisibility(View.GONE);
                return;
            }

            if (item.getFollow_status() == 0) {
                btFans.setText("关注");
                btFans.setBackgroundResource(R.drawable.fans_off);
            } else {
                btFans.setText(item.getFollow_status_text());
                btFans.setBackgroundResource(R.drawable.fans_no);
            }

        }
    }


}